package com.tqjc.execute.task.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tqjc.execute.task.entity.Task;
import com.tqjc.execute.task.entity.TaskApart;
import com.tqjc.execute.task.service.TaskApartService;
import com.tqjc.execute.task.wrapper.TaskApartWrapper;
import com.tqjc.execute.task.wrapper.TaskWrapper;
import com.tqjc.system.core.model.PageInfo;
import com.tqjc.system.core.query.QueryUtils;
import com.tqjc.system.core.util.ResponseUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @projectName: BaotouSteel
 * @className: TaskApartController
 * @author: Patienyon
 * @description: 步骤控制器
 * @date: 2023-07-04 10:49
 */
@Controller
@RequestMapping("/taskApart")
public class TaskApartController {

    @Resource
    TaskApartService taskApartService;

    //辊道管理主页
    @RequestMapping("/index")
    public String index() {
        return "baotou-steel/NormalManage/TaskApartManage.html";
    }

    /**
     * 获取表格数据 树形结构
     *
     * @param
     * @param request
     * @return
     */
    @RequestMapping("/datagrid")
    @ResponseBody
    public void datagrid(TaskApart taskApart, PageInfo<TaskApart> page, HttpServletRequest request, HttpServletResponse response) {
        //拼接查询条件
        QueryWrapper<TaskApart> queryWrapper = QueryUtils.installQueryWrapperRow(taskApart, request.getParameterMap());

        //执行查询
        IPage<TaskApart> lstResult = taskApartService.page(page.getPageEntity(), queryWrapper);

        //结果处理,直接写到客户端
        ResponseUtil.write(response, new TaskApartWrapper(lstResult).wrap());
    }


}
